package com.shop.www.service;

import com.shop.www.daoX.UserDAO;
import com.shop.www.daoX.UserDAOImpl;
import com.shop.www.view.ViewBaseServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

import static com.shop.www.Utils.orempty.notempty;

@WebServlet("/del.do")
public class delete extends ViewBaseServlet {

    UserDAO userDAO = new UserDAOImpl();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       String idstr = request.getParameter("fid");
       if (notempty(idstr)){
           int id = Integer.parseInt(idstr);
           userDAO.deleteuser(id);

           response.sendRedirect("index");

       }
    }
}
